잠시만 기다려 주세요

     '이태원 핼러윈 참사.. 150명 넘게 죽었는데 눈치나 보며 아무것도 안 하는 민주당을 규탄한다. 총선 보이콧... 문재인 시즌2 는 절대 금지다...'
전체검색 :  
이번주 로또 및 연금번호 발생!!   |  HOME   |  여기는?   |  바다물때표   |  알림 (16)  |  여러가지 팁 (1054)  |  추천 및 재미 (150)  |  자료실 (22)  |  
시사, 이슈, 칼럼, 평론, 비평 (582)  |  끄적거림 (127)  |  문예 창작 (702)  |  바람 따라 (69)  |  시나리오 (760)  |  드라마 대본 (248)  |  
살인!


    postgresql

postgresql - Optimize and Improve PostgreSQL Performance with VACUUM, ANALYZE, and REINDEX
이 름 : 바다아이   |   조회수 : 9632         짧은 주소 : https://www.bada-ie.com/su/?791591843263

Purpose

If you have your application running on a PostgreSQL database, there are some commands that can be run to improve and optimize performance. Three of these will be introduced in this article: VACUUM, ANALYZE, and REINDEX.

To avoid conflicting database updates, or corrupted data, it is preferable to run these commands during a maintenance window when the application is stopped.
 

In the default PostgreSQL configuration, the AUTOVACUUM daemon is enabled and all required configuration parameters are set as needed. The daemon will run VACUUM and ANALYZE at regular intervals. If you have the damon enabled, these commands can be run to supplement the daemon's work. To confirm whether the autovacuum daemon is running on UNIX, you can check the processlist

$ ps aux|grep autovacuum|grep -v grep
postgres           334   0.0  0.0  2654128   1232   ??  Ss   16Mar17   0:05.63 postgres: autovacuum launcher process  

On UNIX or Windows, you can find the status of autovacuum in the pg_settings database with the query below:

select name, setting from pg_settings where name = 'autovacuum' ;

VACUUM

The VACUUM command will reclaim space still used by data that had been updated. In PostgreSQL, updated key-value tuples are not removed from the tables when rows are changed, so the VACUUM command should be run occasionally to do this.

VACUUM can be run on its own, or with ANALYZE.

When the option list is surrounded by parentheses, the options can be written in any order. Without parentheses, options must be specified in exactly the order shown below. The parenthesized syntax was added in PostgreSQL 9.0; after which the unparenthesized syntax is deprecated.

Examples

In the examples below, [tablename] is optional. Without a table specified, VACUUM will be run on available tables in the current schema that the user has access to.

  1. Plain VACUUM: Frees up space for re-use

    VACUUM [tablename]
  2. Full VACUUM: Locks the database table, and reclaims more space than a plain VACUUM

    /* Before Postgres 9.0: */
    VACUUM FULL
    /* Postgres 9.0+: */
    VACUUM(FULL) [tablename]
  3. Full VACUUM and ANALYZE: Performs a Full VACUUM and gathers new statistics on query executions paths using ANALYZE

    /* Before Postgres 9.0: */
    VACUUM FULL ANALYZE [tablename]
    /* Postgres 9.0+: */
    VACUUM(FULL, ANALYZE) [tablename]
  4. Verbose Full VACUUM and ANALYZE: Same as #3, but with verbose progress output

    /* Before Postgres 9.0: */
    VACUUM FULL VERBOSE ANALYZE [tablename]
    /* Postgres 9.0+: */
    VACUUM(FULL, ANALYZE, VERBOSE) [tablename]

 

ANALYZE

ANALYZE gathers statistics for the query planner to create the most efficient query execution paths. Per PostgreSQL documentation, accurate statistics will help the planner to choose the most appropriate query plan, and thereby improve the speed of query processing. 

Example

In the example below, [tablename] is optional. Without a table specified, ANALYZE will be run on available tables in the current schema that the user has access to.

ANALYZE VERBOSE [tablename]

 

REINDEX

The REINDEX command rebuilds one or more indices, replacing the previous version of the index. REINDEX can be used in many scenarios, including the following (from Postgres documentation):

  • An index has become corrupted, and no longer contains valid data. Although in theory this should never happen, in practice indexes can become corrupted due to software bugs or hardware failures. REINDEX provides a recovery method.
  • An index has become "bloated", that is it contains many empty or nearly-empty pages. This can occur with B-tree indexes in PostgreSQL under certain uncommon access patterns. REINDEX provides a way to reduce the space consumption of the index by writing a new version of the index without the dead pages.

  • You have altered a storage parameter (such as fillfactor) for an index, and wish to ensure that the change has taken full effect.

  • An index build with the CONCURRENTLY option failed, leaving an "invalid" index. Such indexes are useless but it can be convenient to use REINDEX to rebuild them. Note that REINDEX will not perform a concurrent build. To build the index without interfering with production you should drop the index and reissue the CREATE INDEX CONCURRENTLY command.

Examples

Any of these can be forced by adding the keyword FORCE after the command

  1. Recreate a single index, myindex:

    REINDEX INDEX myindex
  2. Recreate all indices in a table, mytable:

    REINDEX TABLE mytable
  3. Recreate all indices in schema public:

    REINDEX SCHEMA public
  4. Recreate all indices in database postgres:

    REINDEX DATABASE postgres
  5. Recreate all indices on system catalogs in database postgres:

    REINDEX SYSTEM postgres
    
    
    
    출처 : https://confluence.atlassian.com/kb/optimize-and-improve-postgresql-performance-with-vacuum-analyze-and-reindex-885239781.html
    
| |





      1 page / 2 page
번 호 카테고리 제 목 이름 조회수
45 postgresql postgresql ... postgresql 14 .. postgresql.conf port 5432 .. 바다아이 673
44 postgresql , count(*) .... 바다아이 6852
43 postgresql How to do an update + join in PostgreSQL?, 바다아이 6083
42 postgresql sequence(퀀) 바다아이 7716
41 postgresql , , , index create, , 바다아이 8098
40 postgresql postgresql log_timezone .... 바다아이 6501
39 postgresql postgresql SEQUENCE reset .... 바다아이 8337
38 postgresql [PostgreSql] WITH , , Operator 바다아이 7730
37 postgresql postgresql for, foreach , 바다아이 9284
36 postgresql postgresql , , into ... 바다아이 9282
35 postgresql postgresql PL/pgSQL - SQL Procedural Language, , 바다아이 10696
34 postgresql postgresql ... .. , , 바다아이 11711
33 postgresql postgresql CSV export/import 바다아이 8514
32 postgresql postgresql tablespace , .... 바다아이 12837
31 postgresql postgresql 10 partitioning, ... , ... 바다아이 9253
30 postgresql Using PostgreSQL Arrays, ... ... 바다아이 9221
29 postgresql PostgreSQL (TRIGGER) (function) 바다아이 8983
현재글 postgresql Optimize and Improve PostgreSQL Performance with VACUUM, ANALYZE, and REINDEX 바다아이 9633
27 postgresql postgresql tuple . vacuumdb .. , . 바다아이 9029
26 postgresql postgresql , .. 바다아이 9224
25 postgresql postgresql , size, 바다아이 11223
24 postgresql postgresql , , .... 바다아이 8271
23 postgresql PostgreSQL Replication, , , master, slave 바다아이 10771
22 postgresql postgresql case 바다아이 8138
21 postgresql postgresql with 바다아이 8575
20 postgresql postgresql , , string 바다아이 11481
19 postgresql Postgresql partitioning table , , , 바다아이 9072
18 postgresql PostgreSQL 바다아이 10561
17 postgresql postgresql vacuumdb, psql, pg_dump password crontab , pgpass 바다아이 10246
16 postgresql postgresql sequence 퀀 auto_increment . 바다아이 9665
| |









Copyright ⓒ 2001.12. bada-ie.com. All rights reserved.
이 사이트는 리눅스에서 firefox 기준으로 작성되었습니다. 기타 브라우저에서는 다르게 보일 수 있습니다.
[ Ubuntu + GoLang + PostgreSQL + Mariadb ]
서버위치 : 오라클 클라우드 춘천  실행시간 : 0.05572
to webmaster... gogo sea. gogo sea.